package com.zjt.takeoutproject.service.impl;

import com.zjt.takeoutproject.dto.SetmealDto;
import com.zjt.takeoutproject.entity.SetmealDish;
import com.zjt.takeoutproject.mapper.SetmealDishMapper;
import com.zjt.takeoutproject.service.SetmealDishService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 套餐菜品关系 服务实现类
 * </p>
 *
 * @author jobob
 * @since 2023-06-18
 */
@Service
public class SetmealDishServiceImpl extends ServiceImpl<SetmealDishMapper, SetmealDish> implements SetmealDishService {

    //保存菜品信息关系到数据库，即添加信息到SetmealDish表里
    @Override
    public void saveWithDish(SetmealDto setmealDto) {
        List<SetmealDish> setmealDishList=setmealDto.getSetmealDishes();

        for (SetmealDish setmealDish : setmealDishList) {
            setmealDish.setSetmealId(String.valueOf(setmealDto.getId()));
        }
        this.saveBatch(setmealDishList);
    }
}
